package com.kara.woodAgent.agent.model.impl;

import com.kara.woodAgent.agent.model.ModelProvider;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.model.chat.ChatLanguageModel;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * @author tzy
 * @version 1.0
 * @project wood_agent
 * @description
 * @date 2025/6/11 11:03:18
 */
@ConditionalOnProperty(prefix = "model.use",name = "enable",havingValue = "dashscope")
@Component
public class DashscopeModelProvider implements ModelProvider {



	@Value("${model.dashscope.key}")
	private String apiKey;


	@Value("${model.dashscope.name}")
	private String model;

	private QwenChatModel chatModel;

	@PostConstruct
	public void init() {
		chatModel = QwenChatModel.builder()
				.apiKey(apiKey)
				.modelName(model)
				.build();
	}

	@Override
	public ChatLanguageModel getChatModel(String type) {
		return chatModel;
	}
}
